package hu.mapro.gwtui.client.browser;

import hu.mapro.gwtui.client.model.DisplayableValue;

public class TableUtils {

	public static <T, D> ColumnBuilder<T, D> addColumn(TableBuilder<T> tb, final DisplayableValue<T, D> column) {
		return tb.addColumn(new BuildsColumn<T, D>() {
			@Override
			public void build(ColumnBuilder<T, D> builder) {
				buildColumn(builder, column);
			}
		});
	}
	
	public static <T, D> void buildColumn(ColumnBuilder<T, D> cb, DisplayableValue<T, D> column) {
		cb.setAccessor(column);
		cb.setCell(column.getDisplayField());
		cb.setLabel(column.getLabel());
		cb.setPath(column.getPath());
		cb.setWidth(column.getDisplaySize());
	}
	
}
